/** @file poly.cpp
  *
  * Funkcje skladowe klasy wielokata
  */

#include "poly.h"

using namespace std;

Poly::Poly(const Vector2 &o, const int &_n, Vector2 *_tab, const int &c) :
  Object(o, c), n(_n), tab(_tab) {

  tab2 = new int [n*2];

  float minh, maxh, minw, maxw;

  minw = maxw = tab2[0] = tab[0].x;
  minh = maxh = tab2[1] = tab[0].y;

  int j = 2;

  for(unsigned int i = 1; i < n; i++) {
    Vector2 v = tab[i];

    tab2[j++]=v.x;
    tab2[j++]=v.y;

    if(v.x < minw) minw = v.x;
    else if(v.x > maxw) maxw = v.x;

    if(v.y < minh) minh = v.y;
    else if(v.y > maxh) maxh = v.y;
  }

  w = abs(maxw - minw);
  h = abs(maxh - minh);
}

Poly::~Poly(){
  delete [] tab;
  delete [] tab2;
}

/// @bug Ta funkcja to chyba nie dziala.
void Poly::deltaT(const float &dt, const unsigned int &W, const unsigned int &H) {
  //...
}
